#include "ConcreteLightStates.h"

using namespace std;

void LightOff::enter(Light* light)
{
    cout << "enter LightOff..." << endl;
}

void LightOff::toggle(Light* light)
{
    // Off -> Low
    light->setState(LowIntensity::getInstance());
}

void LightOff::exit(Light* light)
{
    cout << "exit LightOff..." << endl;
}

LightState& LightOff::getInstance()
{
    static LightOff singleton;
    return singleton;
}

bool LightOff::operator==(const LightOff& other)
{
    if(this == &other)
        return true;
    else
        return false;
}

void LowIntensity::enter(Light* light)
{
    cout << "enter LowIntensity..." << endl;
}

void LowIntensity::toggle(Light* light)
{
    // Low -> Medium
    light->setState(MediumIntensity::getInstance());
}

void LowIntensity::exit(Light* light)
{
    cout << "exit LowIntensity..." << endl;
}

LightState& LowIntensity::getInstance()
{
    static LowIntensity singleton;
    return singleton;
}

bool LowIntensity::operator==(const LowIntensity& other)
{
    if(this == &other)
        return true;
    else
        return false;
}

void MediumIntensity::enter(Light* light)
{
    cout << "enter MediumIntensity..." << endl;
}

void MediumIntensity::toggle(Light* light)
{
    // Medium -> High
    light->setState(HighIntensity::getInstance());
}

void MediumIntensity::exit(Light* light)
{
    cout << "exit MediumIntensity..." << endl;
}

LightState& MediumIntensity::getInstance()
{
    static MediumIntensity singleton;
    return singleton;
}

bool MediumIntensity::operator==(const MediumIntensity& other)
{
    if(this == &other)
        return true;
    else
        return false;
}

void HighIntensity::enter(Light* light)
{
    cout << "enter HighIntensity..." << endl;
}

void HighIntensity::toggle(Light* light)
{
    // High -> low
    light->setState(LightOff::getInstance());
}

void HighIntensity::exit(Light* light)
{
    cout << "exit HighIntensity..." << endl;
}

LightState& HighIntensity::getInstance()
{
    static HighIntensity singleton;
    return singleton;
}

bool HighIntensity::operator==(const HighIntensity& other)
{
    if(this == &other)
        return true;
    else
        return false;
}

